import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace MemberApi {
  /** 会员信息 */
  export interface Member {
    id: number; // 主键
    code: string; // 会员编号
    userName?: string; // 用户名
    password: string; // 密码
    nickName: string; // 昵称
    gender: number; // 性别
    birthday: string | Dayjs; // 出生日期
    idNumber: string; // 身份证号
    phone?: string; // 联系电话
    email: string; // 电子邮箱
    registerDate: string | Dayjs; // 注册时间
    status?: number; // 状态
  }
}

/** 查询会员分页 */
export function getMemberPage(params: PageParam) {
  return requestClient.get<PageResult<MemberApi.Member>>('/reservation/member/page', { params });
}

/** 查询会员详情 */
export function getMember(id: number) {
  return requestClient.get<MemberApi.Member>(`/reservation/member/get?id=${id}`);
}

/** 新增会员 */
export function createMember(data: MemberApi.Member) {
  return requestClient.post('/reservation/member/create', data);
}

/** 修改会员 */
export function updateMember(data: MemberApi.Member) {
  return requestClient.put('/reservation/member/update', data);
}

/** 删除会员 */
export function deleteMember(id: number) {
  return requestClient.delete(`/reservation/member/delete?id=${id}`);
}

/** 导出会员 */
export function exportMember(params: any) {
  return requestClient.download('/reservation/member/export-excel', params);
}

